home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
301-325
/
disk_319
/
cnewssrc
/
cnews.orig.lzh
/
libfake
/
memchr.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-06-27
|
577b
|
36 lines
/*
* memchr - search for a byte
*
* CHARBITS should be defined only if the compiler lacks "unsigned char".
* It should be a mask, e.g. 0377 for an 8-bit machine.
*/
#define NULL 0
#ifndef CHARBITS
# define UNSCHAR(c) ((unsigned char)(c))
#else
# define UNSCHAR(c) ((c)&CHARBITS)
#endif
char *
memchr(s, ucharwanted, size)
char * s;
int ucharwanted;
int size;
{
register char *scan;
register int n;
register int uc;
scan = s;
uc = UNSCHAR(ucharwanted);
for (n = size; n > 0; n--)
if (UNSCHAR(*scan) == uc)
return(scan);
else
scan++;
return(NULL);
}